package common.ui
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;

	public class BaseView extends Object
	{
		protected var _ui:Sprite;
		protected var _type:String;
		protected var _actions:Object;
		
		public function BaseView()
		{
			_actions = {};
		}
		public function add():void{
			
		}
		public function addTo(toParent:Sprite):void{
			toParent.addChild(_ui);
		}
		public function show():void{
			
		}
		public function close(event:MouseEvent=null):void{
			if(_ui != null && _ui.parent != null){
				_ui.parent.removeChild(_ui);
			}
		}
		public function addUIAction(eventName:String,action:Function):void{
			_actions[eventName] = action;
		}
		protected function doAction(eventName:String):void{
			var fun:Function = _actions[eventName] as Function;
			fun.call();
		}
	}
}